<?php
/*
 * 接口：/receive_record/return
 * 说明：归还领用操作
 */

//关闭事物自动提交
$db->mysqlDB->falseAutoCommit();

//获取请求参数
$params = $route->bodyParams;

//更新领用记录信息
$P1 = array(
  "update_where" => 'orr_id',
  "orr_id" => $params['orr_id'],
  "orr_is_return" => 1,
  "orr_return_time" => time()
);

$R1 = $db->mysqlDB->automaticUpdate($P1)->update("easyd_oa_receive_record");

$inventory = $params['inventory'] + $params['orr_number'];

//更新库存信息
$P2 = array(
  "update_where" => 'oos_id',
  "oos_id" => $params['orr_oosid'],
  "oos_number" => $inventory
);

$R2 = $db->mysqlDB->automaticUpdate($P2)->update("easyd_oa_office_supplies");

if(!$R1||!$R2){
  $db->mysqlDB->rollBackCommint();
  $db->mysqlDB->trueAutoCommit();
  $response->responseData(false);
}else{
  $db->mysqlDB->actionCommint();
  $db->mysqlDB->trueAutoCommit();
  $response->responseData(true);
}
?>